<template>
	<view class="invitation_record">
		<uv-navbar leftIcon="arrow-leftward" leftIconColor="#FFF" placeholder autoBack bgColor="#161714">
			<template v-slot:center>
				<view class="center_slot">邀请记录</view>
			</template>
		</uv-navbar>
		<view class="content">
			<view class="header">
				<view class="item">
					<view class="value">{{count}}</view>
					<view class="key">好友人数</view>
				</view>
				<view class="item">
					<view class="value">{{commission_val}}</view>
					<view class="key">累计佣金($)</view>
				</view>
			</view>
			<view class="tips">好友列表</view>
			<view class="title">
				<view class="key">邮箱</view>
				<view class="value">团队人数</view>
			</view>
			<view class="list">
				<view class="item" v-for="item in _this.list">
					<view class="key">{{item.phone}}</view>
					<view class="value">{{item.team_number}}</view>
				</view>
				<uv-load-more :status="_this.loadmore_status" line @loadmore="loadmore" />
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		userSon
	} from "@/request/api";
	import {
		onReachBottom
	} from "@dcloudio/uni-app"
	import {
		ref,
		shallowRef
	} from "vue";
	import useList from "@/hooks/useList.js";
	const {
		_this
	} = useList();

	const count = ref(0),
		commission_val = ref(0);

	const getList = async () => {
		let {
			list,
			commission
		} = await userSon({
			page: _this.page,
			limit: _this.limit,
		});
		_this.last_page = list.last_page;
		count.value = list.count;
		commission_val.value = commission;
		list = list.list;
		_this.list = _this.page == 1 ? list : [..._this.list, ...list];
		_this.loadmore_status = _this.last_page == _this.page ? 'nomore' : 'loadmore';
	};
	getList();

	const loadmore = () => {
		if (_this.page >= _this.last_page) return;
		_this.page++;
		getList();
	};
	onReachBottom(() => loadmore());
</script>

<style scoped lang="scss">
	.invitation_record {
		.center_slot {
			color: #FFFFFF;
			font-size: 14px;
			font-weight: 800;
		}

		.content {
			padding: 20rpx;
			box-sizing: border-box;

			.header {
				height: 200rpx;
				border-radius: 20rpx;
				padding: 60rpx 0 50rpx;
				box-sizing: border-box;
				background: #2F2F2F;
				display: flex;
				justify-content: space-between;
				position: relative;

				&::after {
					content: "";
					width: 1px;
					height: 72rpx;
					background: rgba(238, 238, 238, 0.2);
					position: absolute;
					left: 50%;
					top: 50%;
					transform: translate(-50%, -50%);
					z-index: 2;
				}

				.item {
					width: 50%;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					align-items: center;

					.value {
						color: #FFFFFF;
						font-size: 40rpx;
						font-weight: bold;
					}

					.key {
						color: #999999;
						font-size: 26rpx;
					}
				}
			}

			.tips {
				color: #FFFFFF;
				font-size: 32rpx;
				padding: 40rpx 20rpx 30rpx;
				box-sizing: border-box;
			}

			.title {
				color: #999999;
				font-size: 26rpx;
				padding: 0 20rpx 28rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
			}

			.list {
				.item {
					height: 80rpx;
					border-bottom: 1px solid rgba(255, 255, 255, 0.1);
					padding: 0 10rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.key {
						color: #DDF247;
						font-size: 26rpx;
					}

					.value {
						color: #FFFFFF;
						font-size: 26rpx;
					}
				}
			}
		}
	}
</style>